import { cloneDeep } from "lodash-es";

export default {
    props: {
        fields: {
            type: Array,
            default: () => [],
        },
        // 请求 api
        httpAdd: Function,
        httpEdit: Function,
        httpGet: Function,
        // 新增 / 编辑 参数处理
        handler: Function,
        // 详情 参数 处理
        getHandler: Function,
        // 参数
        value: {
            type: Object,
            default: () => {},
        },
        // 查看设置为 true 即可
        isLook: {
            type: Boolean,
            default: false,
        },
        // a-row 原生属性
        justify: {
            type: String,
            default: "end",
        },
        width: {
            type: [String, Number],
            default: "45%",
        },
        subText: {
            type: String,
            default: "提交",
        },
        cancelText: {
            type: String,
            default: "取消",
        },
        lookTitle: {
            type: String,
            default: "查看",
        },
        addTitle: {
            type: String,
            default: "新增",
        },
        editTitle: {
            type: String,
            default: "编辑",
        }
    },
    watch: {
        value: {
            handler(newVal) {
                this.$nextTick(() => {
                    this.formValue = cloneDeep({
                        ...this.formValue,
                        ...newVal,
                    });
                });
            },
            deep: true,
            immediate: true,
        },
    },
};
